# create a new koji builder 
# NOTE: should be used with --limit most of the time
# NOTE: make sure there is room/space for this builder on the buildvmhost
# NOTE: most of these vars_path come from group_vars/buildvm or from hostvars

- include: "/srv/web/infra/ansible/playbooks/include/virt-create.yml myhosts=buildvm:buildvm-stg:buildvm-ppc64:buildvm-ppc64le:buildppcle:buildppc"

- name: make koji builder(s)
  hosts: buildvm:buildvm-stg:buildvm-ppc64:buildvm-ppc64le:buildppcle:buildppc
  user: root
  gather_facts: True

  vars_files: 
   - /srv/web/infra/ansible/vars/global.yml
   - "/srv/private/ansible/vars.yml"
   - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml

  pre_tasks:
  - include: "{{ tasks }}/yumrepos.yml"

  roles:
  - base
  - hosts
  - apache
  - { role: nfs/client, 
      when: ansible_architecture == 'x86_64' and not inventory_hostname.startswith('bkernel'), 
      mnt_dir: '/mnt/fedora_koji',  nfs_src_dir: 'fedora_koji' }
  - { role: nfs/client, 
      when: inventory_hostname.startswith('aarch64') , 
      mnt_dir: '/mnt/fedora_koji',  nfs_src_dir: 'fedora_arm/data' }
  - { role: nfs/client, 
      when: inventory_hostname.startswith('buildvm-ppc64') , 
      mnt_dir: '/mnt/fedora_koji',  nfs_src_dir: 'fedora_ppc/data' }
  - { role: nfs/client, 
      when: datacenter == 'staging', mnt_dir: '/mnt/fedora_koji',  nfs_src_dir: 'fedora_koji' }
  - { role: fas_client, when: not inventory_hostname.startswith('bkernel') }
  - { role: sudo, when: not inventory_hostname.startswith('bkernel') }
  - koji_builder

  tasks:
  - include: "{{ tasks }}/2fa_client.yml"
    when: not inventory_hostname.startswith('bkernel')
  - include: "{{ tasks }}/motd.yml"
    when: not inventory_hostname.startswith('bkernel')

  - name: make sure kojid is running
    action: service name=kojid state=running

  handlers:
  - include: "{{ handlers }}/restart_services.yml"
